var HUTAFG = window.HUTAFG = {};
var HuntSdk = {
    first_read: 1,
    succCb: null,
    failCb: null,
    interstitialOptions: null,
    rewardOptions: null,
    ad_type: 0,
    interstitialCooldown: 0,
    rewardCooldown: 0,
    interAdNextTime: 20,
    interAdCloseTime: 5,
    doubleShowInterAd: false,
    threeShowInterAd: false,
    midAfcShowSuccess: false,
    midAfcIsLoading: false,
    bannerAfcShowSuccess: false,
    isAddRewardListener: false,
    isAfterRewardToInterAd:false,
    googleSlotMid: null,
    googleSlotBanner: null,
    isShowTopBannerAd: true,
    googleTopSlotBanner: null,
    note_loadings: ["Loading.", "Loading..", "Loading...", "Loading..", "Loading..."],
    _adLoaded: 0,
    _orientation: 'portrait',
    _checktime: 0,
    game_frame: document.getElementById('game_frame'),
    gameframediv: document.getElementById('gameframediv'),
    _adlength: 50,
    paddingHeight: 10,
    updateInterval: null,
    showAdFn: null,
    shadow_box_div: null,
    isLoadGameEnd: false,
    isRefreshBanner: false,
    isMandatoryDisplayInter: false,
    init: function() {
        document.title = gGame.name;
        if (this._blbanner == 1) {
            HuntSdk._adlength = 100;
        } else {
            HuntSdk._adlength = 50;
        }
        if (window["AD_CONIFG"].bannerType == '' || window["AD_CONIFG"].gdBannerclient == '' || window["AD_CONIFG"].gdBannerSlot == '') {
            HuntSdk._adlength = 0;
            HuntSdk.paddingHeight = 0;
        }
        $(document).ready(function() {
            $(window).trigger('resize');
            _add_ga();
            if (is_afc_loading_page == true) {
                HuntSdk.load_game();
            }
        });
        this.resetGameFrameSize();
        addEventListener('orientationchange', function(event) {
            HuntSdk.orient();
        });
        this.listenWsShowStatus();
    },
    showGame: function() {
        // $("#beginView").hide();
        if (HuntSdk.first_read == 1) {
            HuntSdk.loadAllBanner();
            HuntSdk.first_read = 0;
        }
        if (is_open_more) {
            if (_more_created == 0) {
                create_more_img();
            } else {
                show_more_img();
            }
        }
    },
    load_game: function() {
        HuntSdk.isLoadGameEnd = false;
        this.game_frame.src = "https://www.datinginfo.top/game/ad.html?gameFileName="+gGame.url+'/';
        this.game_frame.addEventListener('contextmenu', function(e) {
            e.preventDefault();
        });
        if (this.game_frame.attachEvent) {
            this.game_frame.attachEvent("onload", _iframe_loaded);
        } else {
            this.game_frame.onload = HuntSdk._iframe_loaded;
        }
        this.gameframediv.addEventListener('contextmenu', function(e) {
            e.preventDefault();
        });
    },
    _iframe_loaded: function() {
        try {
            if (gGame.uid) {
                _clog.sendLog('frame_ready');
            }
        } catch (e) {}
    },
    resetGameFrameSize: function() {
        this.game_frame.addEventListener('contextmenu', function(e) {
            e.preventDefault();
        });
        this.game_frame.addEventListener('contextmenu', function(e) {
            e.preventDefault();
        });
        this.gameframediv.addEventListener('contextmenu', function(e) {
            e.preventDefault();
        });
        var _FrameWidth = document.documentElement.clientWidth;
        var _FrameHeight = document.documentElement.clientHeight - HuntSdk._adlength;
        _FrameHeight = _FrameHeight - HuntSdk.paddingHeight;
        if(HuntSdk.isShowTopBannerAd){
            this.gameframediv.style.top = HuntSdk._adlength + HuntSdk.paddingHeight + "px";
            _FrameHeight = _FrameHeight - HuntSdk._adlength;
            _FrameHeight = _FrameHeight - HuntSdk.paddingHeight;
        }
        if (is_top_banner) {
            this.gameframediv.style.top = HuntSdk._adlength + HuntSdk.paddingHeight + "px";
        } else {
            this.gameframediv.style.bottom = HuntSdk._adlength + HuntSdk.paddingHeight + "px";
        }

        this.game_frame.style.width = _FrameWidth + "px";
        this.game_frame.style.height = _FrameHeight + "px";
        this.gameframediv.style.height = _FrameHeight + "px";
        if (window.orientation == 0 || window.orientation == 180) {
            $('#shadow_box_div').css('padding-top', '30%');
        } else {
            $('#shadow_box_div').css('padding-top', '0');
        }
    },
    _getWinWidth: function() {
        return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
    },
    _getWinHeight: function() {
        return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
    },
    setSize: function() {
        var _w = HuntSdk._getWinWidth();
        var _h = HuntSdk._getWinHeight();
        this._checktime = this._checktime + 1;
        if (this._checktime > 3)
            return;
        if (this._orientation == 'landscape') {
            if (_w < _h) {
                setTimeout(HuntSdk.setSize, 200);
            }
        } else {
            if (_w > _h) {
                setTimeout(HuntSdk.setSize, 200);
            }
        }
        HuntSdk.resetGameFrameSize();
    },
    orient: function() {
        this._checktime = 0;
        if (window.orientation == 0 || window.orientation == 180) {
            $("body").attr("class", "portrait");
            this._orientation = 'portrait';
            setTimeout(HuntSdk.resetGameFrameSize, 200);
            return false;
        } else if (window.orientation == 90 || window.orientation == -90) {
            $("body").attr("class", "landscape");
            this._orientation = 'landscape';
            setTimeout(HuntSdk.resetGameFrameSize, 200);
            return false;
        }
    },
    loadstartBT: function() {
        if (is_open_playprogress) {
            var count = 0;
            $("#playnowprogress-inner").css("width", "0%");
            var timer = setInterval(function(e) {
                count += 5;
                if (count < 95) {
                    HuntSdk.setLoadingProgress(count);
                } else if (count >= 100) {
                    if (HuntSdk.isLoadGameEnd) {
                        HuntSdk.setLoadingProgress(100);
                        clearInterval(timer);
                    }
                }
                if (!HuntSdk.isLoadGameEnd) {
                    $("#playtext").text(HuntSdk.note_loadings[count % 4]);
                }
            }, 600);
        }
    },
    setLoadingProgress: function(progress) {
        if (is_open_playprogress) {
            $("#playnowprogress-inner").css("width", progress + "%");
            if (progress === 100) {
                $("#playtext").text("PLAY");
                $("#playnowprogress-inner").css('backgroundColor', '#009a44');
                HuntSdk.isCanClickPlay = true;
                HuntSdk._adLoaded = 1;
                if (is_auto_close) {
                    this.close_begin_ad();
                }
                this.interstitialCooldown = HuntSdk.interAdNextTime;
            }
        }
    },
    setLoadGameComplete: function() {
        HuntSdk.isLoadGameEnd = true;
        $("#preShadow").hide();
    },
    loadAllBanner: function() {
        HuntSdk.load_Banner1();
        HuntSdk.load_Banner2();

        setInterval(function() {
            if (HuntSdk.isRefreshBanner) {
                // googletag&&googletag.pubads().refresh([HuntSdk.googleSlotBanner,HuntSdk.googleTopSlotBanner]);

                    googletag&&googletag.pubads().refresh([HuntSdk.googleSlotBanner]);

                    googletag&&googletag.pubads().refresh([HuntSdk.googleTopSlotBanner]);

            }
            if (HuntSdk.isMandatoryDisplayInter) {
                HuntSdk.isMandatoryDisplayInter = false;
                HuntSdk.loadAdxInterstitial();
            }
        }, 80000);

        this.orient();
    },
    load_Banner1: function() {
        if (window["AD_CONIFG"].gdBannerclient != '' && window["AD_CONIFG"].gdBannerSlot != '') {
            if (is_top_banner) {
                document.getElementById('top-banner').style.top = 0;
                document.getElementById('top-banner').style.paddingBottom = HuntSdk.paddingHeight + "px";
            } else {
                document.getElementById('top-banner').style.bottom = 0;
                document.getElementById('top-banner').style.paddingTop = HuntSdk.paddingHeight + "px";
            }
            document.getElementById('top-banner').style.height = HuntSdk._adlength + "px";
            $('#top-banner').empty();
            if (window["AD_CONIFG"].bannerType == "AdxAfc") {

                HuntSdk.loadAdxBannerAds(document.getElementById('top-banner'),window["AD_CONIFG"].gdBannerSlot,window["AD_CONIFG"].gdBannerclient);
            } else {
                var startBanner = '<ins class="adsbygoogle" style="display:inline-block;width:100%;height:50px" data-ad-client=' + window["AD_CONIFG"].gdBannerclient + " data-ad-slot=" + window["AD_CONIFG"].gdBannerSlot + '></ins>';
                if (_blbanner == 1) {
                    startBanner = '<ins class="adsbygoogle" style="display:inline-block;width:100%;height:100px" data-ad-client=' + window["AD_CONIFG"].gdBannerclient + " data-ad-slot=" + window["AD_CONIFG"].gdBannerSlot + '></ins>';
                }
                this.bannerAfcShowSuccess = false;

                HuntSdk.loadGoogleAds(document.getElementById('top-banner'), startBanner);
                setTimeout(HuntSdk.listenBannerAfcShowStatus, 500);
            }
        } else {
            document.getElementById('top-banner').style.display = "none";
        }

    },
    load_Banner2(){
        if(HuntSdk.isShowTopBannerAd&&window["AD_CONIFG"].gdBannerclient2 != '' && window["AD_CONIFG"].gdBannerSlot2 != ''){

            HuntSdk.showTopBanner();
        }
    },
    showTopBanner:function () {
        var topBannerDiv = document.getElementById("top_banner_div");
        if(topBannerDiv==null){
            topBannerDiv = document.createElement("div");
            topBannerDiv.id = "top_banner_div";
            topBannerDiv.style.cssText = "background-color: #eeeeee;\n" +
                "    width: 100%;\n" +
                "    z-index: 10;\n" +
                "    justify-content: center;\n" +
                "    display: flex;\n" +
                "    position: absolute;\n" +
                "    flex-direction: column;\n" +
                "    align-items: center;"
            topBannerDiv.style.top = 0;
            topBannerDiv.style.paddingBottom = HuntSdk.paddingHeight + "px";
            document.body.appendChild(topBannerDiv);
        }
        topBannerDiv.style.height = HuntSdk._adlength + "px";
        $('#top_banner_div').empty();
        if (window["AD_CONIFG"].bannerType2 == "AdxAfc") {

            HuntSdk.loadAdxBannerAds(topBannerDiv,window["AD_CONIFG"].gdBannerSlot2,window["AD_CONIFG"].gdBannerclient2);
        } else {
            var startBanner = '<ins class="adsbygoogle" style="display:inline-block;width:100%;height:50px" data-ad-client=' + window["AD_CONIFG"].gdBannerclient2 + " data-ad-slot=" + window["AD_CONIFG"].gdBannerSlot2 + '></ins>';
            if (_blbanner == 1) {
                startBanner = '<ins class="adsbygoogle" style="display:inline-block;width:100%;height:100px" data-ad-client=' + window["AD_CONIFG"].gdBannerclient2 + " data-ad-slot=" + window["AD_CONIFG"].gdBannerSlot2 + '></ins>';
            }
            HuntSdk.bannerAfcShowSuccess = false;
            HuntSdk.loadGoogleAds(topBannerDiv, startBanner);
        }

    },
    listenWsShowStatus: function() {
        if (window["AD_CONIFG"].interType == "AdxAfc" && window["AD_CONIFG"].rewardType != "AdxReward") {
            window.googletag = window.googletag || {
                cmd: []
            };
            googletag.cmd.push(function() {
                googletag.pubads().addEventListener('slotRenderEnded', function(event) {
                    var slot = event.slot;
                    if (HuntSdk.googleSlotMid!=null&&slot === HuntSdk.googleSlotMid) {
                        if (event.isEmpty != false) {
                            HuntSdk.midAfcShowSuccess = false;
                        }
                    } else if (HuntSdk.googleSlotBanner!=null&&slot === HuntSdk.googleSlotBanner) {
                        if (event.isEmpty != false) {
                            HuntSdk.bannerAfcShowSuccess = false;
                            HuntSdk.first_read = 1;
                            if (googletag != null && HuntSdk.googleSlotBanner != null) {
                                googletag.destroySlots([HuntSdk.googleSlotBanner]);
                            }
                        }
                    }
                });
                googletag.pubads().addEventListener('impressionViewable', function(event) {
                    var slot = event.slot;
                    if (HuntSdk.googleSlotMid!=null&&slot === HuntSdk.googleSlotMid) {
                        HuntSdk.midAfcShowSuccess = true;
                    } else if (HuntSdk.googleSlotBanner!=null&&slot === HuntSdk.googleSlotBanner) {
                        HuntSdk.bannerAfcShowSuccess = true;
                    }
                });
            });
        }
    },
    listenBannerAfcShowStatus: function() {
        if (window["AD_CONIFG"].bannerType == "googleAfc") {
            var bannerTimer = setInterval(function() {
                obj = $("#top-banner ins");
                if (obj != null && obj.attr("data-ad-slot") == window["AD_CONIFG"].gdBannerSlot) {
                    var statusMid = obj.attr("data-ad-status");
                    if (statusMid != undefined) {
                        if (statusMid == "filled") {
                            HuntSdk.bannerAfcShowSuccess = true;
                        } else {
                            HuntSdk.bannerAfcShowSuccess = false;
                            HuntSdk.first_read = 1;
                        }
                    }
                    clearInterval(bannerTimer);
                }
            }, 500);
        }
    },
    listenMidAfcShowStatus: function() {
        if (window["AD_CONIFG"].interType == "googleAfc") {
            var midTimer = setInterval(function() {
                var obj = $("#creative ins");
                if (obj != null && obj.attr("data-ad-slot") == window["AD_CONIFG"].gdAfcAdslot) {
                    var statusMid = obj.attr("data-ad-status");
                    if (statusMid != undefined) {
                        if (statusMid == "filled") {
                            HuntSdk.midAfcShowSuccess = true;
                        } else {
                            HuntSdk.midAfcShowSuccess = false;
                        }
                    }
                    clearInterval(midTimer);
                }
            }, 500);
        }
    },
    loadGoogleAds: function(obj, text) {
        obj.innerHTML == '';
        if (obj && text != '') {
            obj.innerHTML = text;
            (adsbygoogle = window.adsbygoogle || []).push({});
        }
    },
    loadAdxAFCAds: function(obj,adSlot,adId) {

        if (obj && adSlot != '' && adId != '') {
            obj.innerHTML == '';
            var interAdSlot = adSlot;//window["AD_CONIFG"].AdxDefineSlot;
            var interAdId = adId;//window["AD_CONIFG"].AdxAfcId;

            // if(HuntSdk.doubleShowInterAd){
            //     interAdSlot = window["AD_CONIFG"].AdxDefineSlot2;
            //     interAdId = window["AD_CONIFG"].AdxAfcId2;
            // }

            window.googletag = window.googletag || {
                cmd: []
            };
            HuntSdk.midAfcShowSuccess = false;
            if (googletag != null && HuntSdk.googleSlotMid != null) {
                googletag.destroySlots([HuntSdk.googleSlotMid]);
            }

            googletag.cmd.push(function() {
                if (is_auto_ads) {
                    HuntSdk.googleSlotMid = googletag.defineSlot(interAdSlot, ['fluid'], interAdId);
                } else {
                    HuntSdk.googleSlotMid = googletag.defineSlot(interAdSlot, [200, 200], interAdId);
                }
                HuntSdk.googleSlotMid.addService(googletag.pubads());
                googletag.pubads().collapseEmptyDivs();
                googletag.pubads().enableSingleRequest();
                googletag.enableServices();
            });
            var innerText = "<div id=" + interAdId + " style='width: 200px; height: 200px;'>";
            if (is_auto_ads) {
                innerText = "<div id=" + interAdId + ">";
            }
            obj.innerHTML = innerText;
            googletag.cmd.push(function() {
                googletag.display(interAdId);
            });
        }
    },
    loadAdxBannerAds: function(obj,bannerSoltID,bannerClientID) {
        if (obj) {
            obj.innerHTML = '';


            if(obj.id=='top_banner_div'){
                if (HuntSdk.googleTopSlotBanner != null) {
                    googletag&&googletag.destroySlots([HuntSdk.googleTopSlotBanner]);
                    HuntSdk.googleTopSlotBanner = null;
                }
            }else{
                if (HuntSdk.googleSlotBanner != null) {
                    googletag&&googletag.destroySlots([HuntSdk.googleSlotBanner]);
                    HuntSdk.googleSlotBanner = null;
                }
            }

            window.googletag = window.googletag || {
                cmd: []
            };
            googletag.cmd.push(function() {
                googletag.pubads().collapseEmptyDivs();
                if(obj.id=='top_banner_div'){
                    HuntSdk.googleTopSlotBanner = googletag.defineSlot(bannerSoltID, [320, 50], bannerClientID);
                    HuntSdk.googleTopSlotBanner.addService(googletag.pubads());
                }else{
                    HuntSdk.googleSlotBanner = googletag.defineSlot(bannerSoltID, [320, 50], bannerClientID);
                    HuntSdk.googleSlotBanner.addService(googletag.pubads());
                }

                googletag.pubads().enableSingleRequest();
                googletag.enableServices();
            });
            var innerText = "<div id=" + bannerClientID + " style='width: 320px; height: 50px;'>";
            obj.innerHTML = innerText;
            googletag.cmd.push(function() {
                googletag.display(bannerClientID);
            });
        }

    },
    loadAdxInterstitial: function() {
        if (HuntSdk.midAfcShowSuccess || HuntSdk.midAfcIsLoading) {
            return;
        }
        if (window["AD_CONIFG"].interType == "AdxINTERSTITIAL" && window["AD_CONIFG"].AdxDefineSlot != '') {
            window.googletag = window.googletag || {
                cmd: []
            };
            googletag.cmd.push(function() {
                if (HuntSdk.googleSlotMid != null) {
                    googletag.destroySlots([HuntSdk.googleSlotMid]);
                    HuntSdk.googleSlotMid = null;
                }
                HuntSdk.googleSlotMid = googletag.defineOutOfPageSlot(window["AD_CONIFG"].AdxDefineSlot, googletag.enums.OutOfPageFormat.INTERSTITIAL);
                googletag.pubads().collapseEmptyDivs();
                googletag.pubads().enableSingleRequest();
                googletag.enableServices();
                HuntSdk.midAfcIsLoading = true;
                if (HuntSdk.googleSlotMid) {
                    HuntSdk.googleSlotMid.addService(googletag.pubads());
                    googletag.display(HuntSdk.googleSlotMid);
                } else {
                    HuntSdk._adLoaded = 1;
                    HuntSdk.midAfcShowSuccess = false;
                    close_begin_ad();
                }
            });
            googletag.cmd.push(function() {
                googletag.pubads().addEventListener('slotOnload', function(event) {
                    console.log("loadAdxInterstitial slotOnload" + new Date().toLocaleString())
                    HuntSdk.midAfcIsLoading = false;
                    var addID = document.getElementsByTagName('ins');
                    for (var i = 0; i < addID.length; i++) {
                        if (addID[i].id.startsWith("gpt_unit_" + window["AD_CONIFG"].AdxDefineSlot)) {
                            document.getElementById(addID[i].id).style.display = 'block';
                            HuntSdk._adLoaded = 1;
                            HuntSdk.midAfcShowSuccess = true;
                            setTimeout(()=>{
                                    close_begin_ad();
                                    HuntSdk.midAfcShowSuccess = false;
                                }
                                , 5000);
                        }
                    }
                });
                googletag.pubads().addEventListener('slotRenderEnded', function(event) {
                    var slot = event.slot;
                    if (slot === HuntSdk.googleSlotMid) {
                        if (event.isEmpty != false) {
                            HuntSdk._adLoaded = 1;
                            HuntSdk.midAfcShowSuccess = false;
                            close_begin_ad();
                        }
                    }
                });
            });
        }
    },
    showAdxOldAfg: function() {
        if (HuntSdk.midAfcShowSuccess || HuntSdk.midAfcIsLoading) {
            console.log("showAdxOldAfg return")
            return;
        }
        HuntSdk.midAfcIsLoading = true;
        const options = {
            debug: false,
            adsStart: function() {},
            adsError: function(code) {
                HuntSdk.midAfcIsLoading = false;
                if (code == '1009') {
                    failLoadToClose();
                } else {
                    failLoadToClose();
                }
            },
            adsSuccess: function() {
                HuntSdk.midAfcIsLoading = false;
                HuntSdk._adLoaded = 1;
                HuntSdk.midAfcShowSuccess = false;
                close_begin_ad();
            },
            adsComplete: function() {
                HuntSdk.midAfcIsLoading = false;
                HuntSdk._adLoaded = 1;
                HuntSdk.midAfcShowSuccess = true;
                close_begin_ad();
                HuntSdk.midAfcShowSuccess = false;
            }
        };
        HuntAds.init(options);
        HuntAds.loadAds();
    },
    showAdxReward: function() {
        HuntSdk.loadAdxReward();
    },
    loadAdxReward: function() {
        if (HuntSdk.midAfcShowSuccess || HuntSdk.midAfcIsLoading) {
            return;
        }
        if (window["AD_CONIFG"].AdxRewardSlot != '') {
            window.googletag = window.googletag || {
                cmd: []
            };
            googletag.cmd.push(function() {
                if (HuntSdk.googleSlotMid != null) {
                    googletag.destroySlots([HuntSdk.googleSlotMid]);
                    HuntSdk.googleSlotMid = null;
                }
                HuntSdk.googleSlotMid = googletag.defineOutOfPageSlot(window["AD_CONIFG"].AdxRewardSlot, googletag.enums.OutOfPageFormat.REWARDED);
                HuntSdk.midAfcIsLoading = true;
                if (HuntSdk.googleSlotMid) {
                    HuntSdk.googleSlotMid.addService(googletag.pubads());
                } else {
                    HuntSdk._adLoaded = 1;
                    HuntSdk.midAfcShowSuccess = false;
                    close_begin_ad();
                }
            });
            googletag.cmd.push(function() {
                if (!HuntSdk.isAddRewardListener) {
                    googletag.pubads().addEventListener('rewardedSlotReady', function(event) {
                        event.makeRewardedVisible();
                    });
                    googletag.pubads().addEventListener('slotRenderEnded', function(event) {
                        HuntSdk.midAfcIsLoading = false;
                        if (event.isEmpty) {
                            HuntSdk.loadAfcAd2()
                        }
                    });
                    googletag.pubads().addEventListener('rewardedSlotClosed', function() {
                        googletag.destroySlots([HuntSdk.googleSlotMid])
                        HuntSdk._adLoaded = 1;

                        if(HuntSdk.isAfterRewardToInterAd){
                            HuntSdk.loadAfcAd2();
                        }else{
                            close_begin_ad();
                        }

                        HuntSdk.midAfcShowSuccess = false;
                    });
                    googletag.pubads().addEventListener('rewardedSlotGranted', function(event) {
                        HuntSdk._adLoaded = 1;
                        HuntSdk.midAfcShowSuccess = true;
                    });
                }
                HuntSdk.isAddRewardListener = true;
                googletag.enableServices();
                googletag.pubads().collapseEmptyDivs();
                googletag.display(HuntSdk.googleSlotMid);
            });
        }
    },
    loadAfcAd2: function() {

        if (window["AD_CONIFG"].interType != "AdxAfc"){
            return;
        }
        this._adLoaded = 0;

        this.shadow_box_div = document.getElementById("shadow_box_div");
        if (this.shadow_box_div == null) {
            this.shadow_box_div = document.createElement("div");
            this.shadow_box_div.id = "shadow_box_div";
            this.shadow_box_div.style.cssText = "    background: rgba(52,58,65,.7);\n" + "    -webkit-backdrop-filter: blur(15px);\n" + "    backdrop-filter: blur(15px);\n" + "    height: 100vh;\n" + "    width: 100%;\n" + "    position: absolute;\n" + "    z-index: 100000;";
            document.body.appendChild(this.shadow_box_div);
        }else{
            return;
        }
        $('#shadow_box_div').empty();
        var subDiv = document.createElement("div");
        subDiv.id = 'subDiv';
        subDiv.style.cssText = "    height: 100vh;\n" + "    width: 100%;\n" + "    position: fixed;\n";
        $('#shadow_box_div').append(subDiv);
        var ad_position_box_div = document.createElement("div");
        ad_position_box_div.id = 'ad_position_box';
        ad_position_box_div.style.cssText = "    display: -webkit-box;\n" + "    -webkit-box-align: center;\n" + "    -webkit-box-pack: center;\n" + "    justify-content: center;\n" + "    height: 100%;\n" + "    width: 100%;";
        $('#subDiv').append(ad_position_box_div);
        var card_div = document.createElement("div");
        card_div.id = 'card';
        card_div.style.cssText = "border-radius: 8px;\n" + "    height: 100%;\n" + "    width: 100%;";
        $('#ad_position_box').append(card_div);
        var toprow_div = document.createElement("div");
        toprow_div.id = 'toprow';
        toprow_div.style.cssText = "width: 100%;\n" + "    font-family: Roboto,arial,sans-serif;\n" + "    height: 40px;\n" + "    position: relative;\n" + "    background-color: #424242;";
        $('#card').append(toprow_div);
        var btn_skip_div = document.createElement("div");
        btn_skip_div.id = 'btn_skip';
        btn_skip_div.style.cssText = '    font-family: Roboto,arial,sans-serif;\n' + '    font-size: 18px;\n' + '    touch-action: pan-y;\n' + "    position: absolute;\n" + '    box-sizing: border-box;\n' + '    word-wrap: break-word;\n' + '    opacity: .95;\n' + '    right: 0;\n' + '    top: 10px;\n' + '    line-height: 30px;\n' + '    -webkit-transition: opacity 1s,background .75s;\n' + '    height: 30px;\n' + '    background: 0 0;\n' + '    z-index: 9999;\n' + '    color: #fff;';
        $('#toprow').append(btn_skip_div);
        var count_down_container_div = document.createElement("div");
        count_down_container_div.id = 'count_down_container';
        count_down_container_div.style.cssText = '    font-family: \'Roboto\', arial, sans-serif;\n' + '    font-size: 10px;\n' + '    margin: 0;\n' + '    outline: none;\n' + '    height: 30px;\n' + '    line-height: 30px;\n' + '    color: #FFF;\n' + '    border-radius: 1.8em;\n' + '    background: rgba(0,0,0,0.3);\n' + '    transition: background 0.5s ease;\n' + '    vertical-align: middle;\n' + '    padding: 0 0.55em;';
        $('#btn_skip').append(count_down_container_div);
        var count_down_div = document.createElement("div");
        count_down_div.id = 'count_down';
        count_down_div.style.cssText = '    font-family: \'Roboto\', arial, sans-serif;\n' + '    font-size: 18px;\n' + '    color: #FFF;\n' + '    margin: 0;\n' + '    outline: none;\n' + '    vertical-align: middle;\n' + '    padding: 0 0.25em;\n' + '    display: table-cell;';
        $('#count_down_container').append(count_down_div);
        var count_down_text_div = document.createElement("div");
        count_down_text_div.id = 'count_down_text';
        count_down_text_div.style.cssText = '    font-family: \'Roboto\', arial, sans-serif;\n' + '    color: #FFF;\n' + '    margin: 0;\n' + '    padding: 0;\n' + '    outline: none;\n' + '    font-size: 10px;';
        if(HuntSdk.threeShowInterAd==true
            &&window["AD_CONIFG"].AdxDefineSlot3!=""
            &&window["AD_CONIFG"].AdxAfcId3!=""){
            count_down_text_div.innerText = 'Close in ' + HuntSdk.interAdCloseTime*3 + ' seconds';
        }else if(HuntSdk.doubleShowInterAd==true
            &&window["AD_CONIFG"].AdxDefineSlot2!=""
            &&window["AD_CONIFG"].AdxAfcId2!=""){
            count_down_text_div.innerText = 'Close in ' + HuntSdk.interAdCloseTime*2 + ' seconds';
        }else{
            count_down_text_div.innerText = 'Close in ' + HuntSdk.interAdCloseTime + ' seconds';
        }
        $('#count_down').append(count_down_text_div);
        var dismiss_button_element_div = document.createElement("div");
        dismiss_button_element_div.id = 'dismiss_button_element';
        dismiss_button_element_div.style.cssText = '    font-family: \'Roboto\', arial, sans-serif;\n' + '    font-size: 18px;\n' + '    color: #FFF;\n' + '    outline: none;\n' + '    line-height: 40px;\n' + '    margin-right: 5px;\n' + '    display: none;';
        $('#btn_skip').append(dismiss_button_element_div);
        $('#dismiss_button_element').append("<div><svg style = \"height: 1.3em;\n" + "    width: 1.3em;\n" + "    padding-bottom: 1px;\" viewBox=\"0 0 48 48\" fill=\"#FFFFFF\"><path d=\"M38 12.83L35.17 10 24 21.17 12.83 10 10 12.83 21.17 24 10 35.17 12.83 38 24 26.83 35.17 38 38 35.17 26.83 24z\"></path> <path d=\"M0 0h48v48H0z\" fill=\"none\"></path></svg></div>");
        $('#dismiss_button_element').hide();
        $('#dismiss_button_element').on('click', function() {
            HuntSdk.midAfcShowSuccess = true;
            close_begin_ad();
            HuntSdk.midAfcShowSuccess = false;
            $('#shadow_box_div').remove();
            $('#shadow_box_div').empty();
            $('#shadow_box_div').hide();

        });
        $('#toprow').append("<div style='    font-family: Roboto,arial,sans-serif;\n" + "    font-size: 18px;\n" + "    width: 100%;\n" + "    height: 50px;\n" + "    position: absolute;\n" + "    color: #ffffff;\n" + "    display: table;'><div class=\"text\" style=\"text-align: center;display: table-cell;vertical-align: middle;\">Ad</div></div>");
        var creative_div = document.createElement("div");
        creative_div.id = 'creative';
        creative_div.style.cssText = '    width: 100%;\n' + '    height: 100%;\n' + '    position: relative;';
        $('#card').append(creative_div);
        HuntSdk.midadisbanner = false;
        HuntSdk.showSubAdxInterAds(window["AD_CONIFG"].AdxAfcId,window["AD_CONIFG"].AdxDefineSlot);

        $('#shadow_box_div').show();
        ad_req();
        hidden_more_img();
        this.loadclosebtn();
    },
    showSubAdxInterAds:function (adxId,adxSlot){
        $('#creative').empty();
        if (window["AD_CONIFG"].interType == "AdxAfc") {
            if (!is_auto_ads) {
                var childAdDiv = "<div id='div_afc_adContainer' style='width: 200px;height: 200px;top: 60%;left: 50%;transform: translate(-50%,-70%); position: absolute;'></div>";
                $('#creative').append(childAdDiv);
                HuntSdk.loadAdxAFCAds(document.getElementById('div_afc_adContainer'),
                    adxSlot,adxId);
            } else {
                HuntSdk.loadAdxAFCAds(document.getElementById('creative'),
                    adxSlot,adxId);
            }
        } else {
            var startAds = '<ins class="adsbygoogle" style="display:inline-block;width:300px;height:250px" data-ad-client=' + window["AD_CONIFG"].gdAdclient + ' data-ad-slot=' + window["AD_CONIFG"].gdAfcAdslot + '></ins>';
            if (is_auto_ads) {
                startAds = '<ins class="adsbygoogle" style="display:block;" data-ad-client=' + window["AD_CONIFG"].gdAdclient + ' data-ad-slot=' + window["AD_CONIFG"].gdAfcAdslot + ' " data-ad-format="auto" data-full-width-responsive="true"' + '></ins>';
            }
            HuntSdk.midAfcShowSuccess = false;
            HuntSdk.loadGoogleAds(document.getElementById('creative'), startAds);
            setTimeout(HuntSdk.listenMidAfcShowStatus, 500);
        }
    },
    loadclosebtn: function() {
        var count = HuntSdk.interAdCloseTime;
        if(HuntSdk.threeShowInterAd==true
            &&window["AD_CONIFG"].AdxDefineSlot3!=""
            &&window["AD_CONIFG"].AdxAfcId3!="") {
            count = HuntSdk.interAdCloseTime*3;
        }else if(HuntSdk.doubleShowInterAd==true
                &&window["AD_CONIFG"].AdxDefineSlot2!=""
                &&window["AD_CONIFG"].AdxAfcId2!=""){
                count = HuntSdk.interAdCloseTime*2;
        }
        $('#count_down_container').css("font-size", '10px');
        var timer = setInterval(function(e) {
            count -= 1;
            if (count === 0) {
                HuntSdk._adLoaded = 1;
                if (is_auto_close && HuntSdk.ad_type == 1) {
                    HuntSdk.close_begin_ad();
                    $('#shadow_box_div').empty();
                    $('#shadow_box_div').hide();
                    $('#shadow_box_div').remove();
                }
                $('#count_down_container').hide();
                $('#dismiss_button_element').show();
                clearInterval(timer);
            } else {
                $('#count_down_container').text("Close in " + count + " seconds");
                if(count==HuntSdk.interAdCloseTime*2
                    &&HuntSdk.threeShowInterAd==true
                    &&window["AD_CONIFG"].AdxDefineSlot3!=""
                    &&window["AD_CONIFG"].AdxAfcId3!=""){

                    HuntSdk.showSubAdxInterAds(window["AD_CONIFG"].AdxAfcId3,window["AD_CONIFG"].AdxDefineSlot3);

                }else if(count==HuntSdk.interAdCloseTime
                    &&HuntSdk.doubleShowInterAd==true
                    &&window["AD_CONIFG"].AdxDefineSlot2!=""
                    &&window["AD_CONIFG"].AdxAfcId2!=""){

                    HuntSdk.showSubAdxInterAds(window["AD_CONIFG"].AdxAfcId2,window["AD_CONIFG"].AdxDefineSlot2);

                }
            }
        }, 1000);
    },
    loadSplashAd: function() {
        this._adLoaded = 0;
        if (!is_open_playprogress) {
            document.getElementById('playnow').style.visibility = 'hidden';
        } else {
            document.getElementById('playnow').style.visibility = 'visible';
            $("#playtext").text("loading.");
            $("#playnowprogress-inner").css("width", "0%");
        }

        if (window["AD_CONIFG"].interType == "AdxAfc") {
            if (!is_auto_ads) {
                var childAdDiv = "<div id='div_afc_adContainer' style='width: 200px;height: 200px;margin: 0 auto;padding-bottom: 10px;padding-top: 10px;overflow: hidden; background: rgb(255, 255, 255); display: block;'></div>";
                $('#pop-ad').append(childAdDiv);
                this.loadAdxAFCAds(document.getElementById('div_afc_adContainer'),
                    window["AD_CONIFG"].AdxDefineSlot,window["AD_CONIFG"].AdxAfcId);
            } else {
                this.loadAdxAFCAds(document.getElementById('pop-ad'),
                    window["AD_CONIFG"].AdxDefineSlot,window["AD_CONIFG"].AdxAfcId);
            }
        } else {
            var startAds = '<ins class="adsbygoogle" style="display:inline-block;width:300px;height:250px" data-ad-client=' + window["AD_CONIFG"].gdAdclient + ' data-ad-slot=' + window["AD_CONIFG"].gdAfcAdslot + '></ins>';
            if (is_auto_ads) {
                startAds = '<ins class="adsbygoogle" style="display:block;" data-ad-client=' + window["AD_CONIFG"].gdAdclient + ' data-ad-slot=' + window["AD_CONIFG"].gdAfcAdslot + ' " data-ad-format="auto" data-full-width-responsive="true"' + '></ins>';
            }
            this.midAfcShowSuccess = false;
            this.loadGoogleAds(document.getElementById('pop-ad'), startAds);
            setTimeout(HuntSdk.listenMidAfcShowStatus, 500);
        }
        ad_req();
        HuntSdk.loadstartBT();
        hidden_more_img();
    },
    close_begin_ad_newAfg: function() {
        if (this._adLoaded == 0)
            return;
        HuntSdk.showGame();
        if (HuntSdk.ad_type == 1) {
            HuntSdk.interstitialCooldown = HuntSdk.interAdNextTime;
        }
        first_cdr_ready();
        $('#pop-ad').empty();
        if (window["AD_CONIFG"].interType == "AdxAfc" || window["AD_CONIFG"].interType == "AdxINTERSTITIAL" || window["AD_CONIFG"].interType == "AdxReward") {
            window.googletag = window.googletag || {
                cmd: []
            };
            if (googletag != null && HuntSdk.googleSlotMid != null) {
                googletag.destroySlots([HuntSdk.googleSlotMid]);
            }
        }
        if (HuntSdk.ad_type == 1 && HuntSdk.interstitialOptions && HuntSdk.interstitialOptions.afterShowAd) {
            HuntSdk.interstitialOptions.afterShowAd();
            HuntSdk.interstitialOptions.afterShowAd = null;
        }
        if (HuntSdk.ad_type == 2) {
            if (HuntSdk.midAfcShowSuccess) {
                HuntSdk.succCb && HuntSdk.succCb();
                HuntSdk.succCb = null;
                if (HuntSdk.rewardOptions != null) {
                    HuntSdk.rewardOptions.rewardComplete && HuntSdk.rewardOptions.rewardComplete();
                    HuntSdk.rewardOptions.rewardComplete = null;
                }
            } else {
                HuntSdk.failCb && HuntSdk.failCb();
                HuntSdk.failCb = null;
            }
            if (HuntSdk.rewardOptions != null) {
                HuntSdk.rewardOptions.afterShowAd && HuntSdk.rewardOptions.afterShowAd();
                HuntSdk.rewardOptions.afterShowAd = null;
            }
        }
    },
    showInterstitial: function(options) {
        HuntSdk.interstitialOptions = options;
        HuntSdk.ad_type = 1;
        HuntSdk.interstitialCooldown = -1;
        if (HuntSdk.interstitialCooldown < 0) {
            if (window["AD_CONIFG"].interType == "googleNewAfg") {
                HuntSdk.showNewAfgInterstitial();
            } else if (window["AD_CONIFG"].interType == "AdxINTERSTITIAL" || window["AD_CONIFG"].interType == "AdxAfc") {
                HuntSdk.showAFCInterstitial();
            } else if (window["AD_CONIFG"].interType == "AdxReward") {
                HuntSdk.showAdxReward();
            } else if (window["AD_CONIFG"].interType == "AdxOldAfg") {
                HuntSdk.showAdxOldAfg();
            } else if (HuntSdk.interstitialOptions && HuntSdk.interstitialOptions.afterShowAd) {
                HuntSdk.interstitialOptions.afterShowAd();
                HuntSdk.interstitialOptions.afterShowAd = null;
            }
        } else if (HuntSdk.interstitialOptions && HuntSdk.interstitialOptions.afterShowAd) {
            HuntSdk.interstitialOptions.afterShowAd();
            HuntSdk.interstitialOptions.afterShowAd = null;
        }
    },
    showNewAfgInterstitial: function() {
        if (window["AD_CONIFG"].interType != "googleNewAfg") {
            if (HuntSdk.interstitialOptions && HuntSdk.interstitialOptions.afterShowAd) {
                HuntSdk.interstitialOptions.afterShowAd();
                HuntSdk.interstitialOptions.afterShowAd = null;
            }
            return;
        }
        var nType = "next";
        if (HuntSdk.ad_type == 0) {
            nType = "start";
        } else {
            nType = "next";
        }
        window.adBreak({
            type: nType,
            name: 'game_' + nType,
            beforeAd: ()=>{
                if (HuntSdk.ad_type == 1 && HuntSdk.interstitialOptions && HuntSdk.interstitialOptions.beforeShowAd) {
                    HuntSdk.interstitialOptions.beforeShowAd();
                    HuntSdk.interstitialOptions.beforeShowAd = null;
                }
                ad_req();
                window.blur();
            }
            ,
            afterAd: ()=>{
                HuntSdk.showGame();
                ad_show();
                if (HuntSdk.interstitialOptions && HuntSdk.interstitialOptions.afterShowAd) {
                    HuntSdk.interstitialOptions.afterShowAd();
                    HuntSdk.interstitialOptions.afterShowAd = null;
                }
                this.interstitialCooldown = HuntSdk.interAdNextTime;
                window.focus();
            }
            ,
            adBreakDone: (placementInfo)=>{
                if (placementInfo.breakStatus != "viewed" && window["AD_CONIFG"].interType != "") {
                    HuntSdk.showAFCInterstitial();
                } else {
                    if (HuntSdk.interstitialOptions && HuntSdk.interstitialOptions.afterShowAd) {
                        HuntSdk.interstitialOptions.afterShowAd();
                        HuntSdk.interstitialOptions.afterShowAd = null;
                    }
                }
            }
        });
    },
    showAFCInterstitial: function() {
        if (HuntSdk.ad_type == 1 && HuntSdk.interstitialOptions && HuntSdk.interstitialOptions.beforeShowAd) {
            HuntSdk.interstitialOptions.beforeShowAd();
            HuntSdk.interstitialOptions.beforeShowAd = null;
        }
        if (window["AD_CONIFG"].interType == "") {
            if (HuntSdk.interstitialOptions && HuntSdk.interstitialOptions.afterShowAd) {
                HuntSdk.interstitialOptions.afterShowAd();
                HuntSdk.interstitialOptions.afterShowAd = null;
            }
            HuntSdk.showGame();
            return;
        }
        if (window["AD_CONIFG"].interType == "AdxINTERSTITIAL") {
            HuntSdk.loadAdxInterstitial();
        } else if (window["AD_CONIFG"].interType == "AdxReward") {
            HuntSdk.loadAdxReward();
        } else {

            HuntSdk.loadAfcAd2();
        }
    },
    showReward: function(options) {
        HuntSdk.ad_type = 2;
        if (window["AD_CONIFG"].rewardType == "AdxAfc" && document.getElementById("shadow_box_div")!=null) {
            //ADX AfC is showing
            if (HuntSdk.rewardOptions!=null) {
                HuntSdk.rewardOptions.rewardDismissed && HuntSdk.rewardOptions.rewardDismissed();
                HuntSdk.rewardOptions.rewardDismissed = null;
                HuntSdk.rewardOptions.afterShowAd && HuntSdk.rewardOptions.afterShowAd();
                HuntSdk.rewardOptions.afterShowAd = null;
            }
            if (HuntSdk.failCb != null) {
                HuntSdk.failCb();
                HuntSdk.failCb = null;
            }
            return
        }
        HuntSdk.rewardOptions = options;
        if (window["AD_CONIFG"].rewardType == "googleNewAfg") {
            HuntSdk.showNewAfgReward();
        } else if (window["AD_CONIFG"].rewardType == "AdxReward") {
            HuntSdk.showAdxReward();
        } else if (window["AD_CONIFG"].rewardType == "AdxOldAfg") {
            HuntSdk.showAdxOldAfg();
        } else if (window["AD_CONIFG"].rewardType != "") {
            HuntSdk.showAfcReward()
        }
    },
    checkNewAfgReward() {
        if (HuntSdk.showAdFn)
            return;
        window.adBreak({
            type: "reward",
            name: "reward",
            beforeAd: HuntSdk.onRewardBeforeBreak.bind(this),
            afterAd: HuntSdk.onRewardAfterBreak.bind(this),
            beforeReward: HuntSdk.onBeforeReward.bind(this),
            adDismissed: HuntSdk.onRewardDismissed.bind(this),
            adViewed: HuntSdk.onRewardComplete.bind(this),
            adBreakDone: (placementInfo)=>{
                if (placementInfo.breakStatus != "viewed" && placementInfo.breakStatus != "dismissed") {}
            }
        });
    },
    onBeforeReward(showAdFn) {
        showAdFn();
    },
    onRewardBeforeBreak() {
        if (HuntSdk.rewardOptions) {
            HuntSdk.rewardOptions.beforeShowAd && HuntSdk.rewardOptions.beforeShowAd();
            HuntSdk.rewardOptions.beforeShowAd = null;
        }
        ad_req();
    },
    onRewardAfterBreak() {
        window.focus();
        if (HuntSdk.rewardOptions) {
            HuntSdk.rewardOptions.afterShowAd && HuntSdk.rewardOptions.afterShowAd();
            HuntSdk.rewardOptions.afterShowAd = null;
        }
        HuntSdk.showAdFn = null;
        HuntSdk.showGame();
    },
    onRewardDismissed() {
        if (HuntSdk.rewardOptions) {
            HuntSdk.rewardOptions.rewardDismissed && HuntSdk.rewardOptions.rewardDismissed();
            HuntSdk.rewardOptions.rewardDismissed = null;
        }
        if (HuntSdk.failCb != null) {
            HuntSdk.failCb();
            HuntSdk.failCb = null;
        }
    },
    onRewardComplete() {
        if (HuntSdk.rewardOptions) {
            HuntSdk.rewardOptions.rewardComplete && HuntSdk.rewardOptions.rewardComplete();
            HuntSdk.rewardOptions.rewardComplete = null;
        }
        ad_show();
        if (HuntSdk.succCb != null) {
            HuntSdk.succCb();
            HuntSdk.succCb = null;
        }
    },
    onUpdateAds() {
        if (HuntSdk.interstitialCooldown >= 0) {
            HuntSdk.interstitialCooldown--;
            if (HuntSdk.first_read == 1 && HuntSdk.interstitialCooldown % 5 == 0) {
                HuntSdk.loadAllBanner();
                HuntSdk.first_read = 0;
            }
            HuntSdk.interstitialCooldown--;
        }
        if (HuntSdk.rewardCooldown >= 0) {
            HuntSdk.rewardCooldown--;
        }
    },
    canShowReward() {
        if (HuntSdk.showAdFn || HuntSdk.rewardCooldown < 0) {
            return true
        } else {
            return false
        }
    },
    showNewAfgReward: function() {
        if (window["AD_CONIFG"].rewardType != "googleNewAfg" || !this.canShowReward()) {
            if (HuntSdk.rewardOptions) {
                HuntSdk.rewardOptions.beforeShowAd && HuntSdk.rewardOptions.beforeShowAd();
                HuntSdk.rewardOptions.beforeShowAd = null;
            }
            if (window["AD_CONIFG"].interType != "") {
                HuntSdk.showAfcReward();
                window.blur();
            } else {
                if (HuntSdk.failCb != null) {
                    HuntSdk.failCb();
                    HuntSdk.failCb = null;
                }
                if (HuntSdk.rewardOptions) {
                    HuntSdk.rewardOptions.rewardDismissed && HuntSdk.rewardOptions.rewardDismissed();
                    HuntSdk.rewardOptions.rewardDismissed = null;
                    HuntSdk.rewardOptions.afterShowAd && HuntSdk.rewardOptions.afterShowAd();
                    HuntSdk.rewardOptions.afterShowAd = null;
                }
                HuntSdk.showGame();
            }
            return;
        }
        window.blur();
        window.adBreak({
            type: "reward",
            name: 'game_reward',
            beforeAd: HuntSdk.onRewardBeforeBreak.bind(this),
            afterAd: HuntSdk.onRewardAfterBreak.bind(this),
            beforeReward: HuntSdk.onBeforeReward.bind(this),
            adDismissed: HuntSdk.onRewardDismissed.bind(this),
            adViewed: HuntSdk.onRewardComplete.bind(this),
            adBreakDone: (placementInfo)=>{
                if (placementInfo.breakStatus != "viewed" && placementInfo.breakStatus != "dismissed") {}
            }
        });
    },
    showAfcReward: function() {
        if (HuntSdk.rewardOptions != null) {
            HuntSdk.rewardOptions.beforeShowAd && HuntSdk.rewardOptions.beforeShowAd();
            HuntSdk.rewardOptions.beforeShowAd = null;
        }
        if (window["AD_CONIFG"].interType == "") {
            if (HuntSdk.rewardOptions) {
                HuntSdk.rewardOptions.rewardDismissed && HuntSdk.rewardOptions.rewardDismissed();
                HuntSdk.rewardOptions.rewardDismissed = null;
                HuntSdk.rewardOptions.afterShowAd && HuntSdk.rewardOptions.afterShowAd();
                HuntSdk.rewardOptions.afterShowAd = null;
            }
            if (HuntSdk.failCb != null) {
                HuntSdk.failCb();
                HuntSdk.failCb = null;
            }
            HuntSdk.showGame();
            return;
        }
        if (window["AD_CONIFG"].interType == "AdxINTERSTITIAL") {
            HuntSdk.loadAdxInterstitial();
        } else if (window["AD_CONIFG"].interType == "AdxReward") {
            HuntSdk.loadAdxReward();
        } else {
            HuntSdk.loadAfcAd2();
        }
    },
    gotoStart: function() {
        if (is_afc_loading_page == false) {
            HuntSdk.load_game();
        }
    },
    showPreroll: function() {
        HuntSdk.ad_type = 0;
        window.adBreak({
            type: 'preroll',
            name: 'startGame',
            adBreakDone: (placementInfo)=>{}
        });
    },
    showHutSplash: function() {
        HuntSdk.ad_type = 0;
        HuntSdk.interstitialOptions = null;
        if (window["AD_CONIFG"].interType != "AdxINTERSTITIAL") {
            HuntSdk.loadSplashAd();
        }
    },
    playHutAd: function() {
        // var nowTime = new Date();
        HuntSdk.ad_type = 1;
        HuntSdk.showInterstitial(null)
    },
    playHutRewardedAd: function() {
        HuntSdk.ad_type = 2;
        return new Promise(function(resolve, reject) {
                if (window["AD_CONIFG"].rewardType == "AdxAfc" && document.getElementById("shadow_box_div")!=null) {
                    //ADX AfC is showing
                    try{
                        reject&&reject();
                    }catch (e) {
                    }
                    return;
                }
                HuntSdk.succCb = resolve;
                HuntSdk.failCb = reject;
                HuntSdk.showReward(null);
            }
        );
    }
};
function close_begin_ad() {
    HuntSdk.close_begin_ad_newAfg();
}
function failLoadToClose() {
    HuntSdk._adLoaded = 1;
    HuntSdk.midAfcShowSuccess = false;
    close_begin_ad();
    if (HuntSdk.ad_type == 2) {
        showMsgBox("Failed to load ad, please try again")
    }
}
var _start_Game = 0;
function first_cdr_ready() {}
function ad_req() {}
function ad_show() {}
function queryURLparamsRegEs6(url) {
    let obj = {};
    let reg = /([^?=&]+)=([^?=&]+)/g;
    url.replace(reg, (...arg)=>{
            obj[arg[1]] = arg[2];
        }
    );
    return obj;
}
function showNewAfgShadow() {
    if (window["AD_CONIFG"].rewardType == "") {
        return;
    }
    var preShadow_div = document.createElement("div");
    preShadow_div.id = 'preShadow';
    document.body.appendChild(preShadow_div);
    $("#preShadow").addClass('preShadow');
    var preloadpacman_div = document.createElement("div");
    preloadpacman_div.id = 'preloadpacman';
    $('#preShadow').append(preloadpacman_div);
    $("#preloadpacman").addClass('preloadpacman');
    var preShadow_child1_div = document.createElement("div");
    $('#preloadpacman').append(preShadow_child1_div);
    var preShadow_child2_div = document.createElement("div");
    $('#preloadpacman').append(preShadow_child2_div);
    var preShadow_child3_div = document.createElement("div");
    $('#preloadpacman').append(preShadow_child3_div);
    var preShadow_child4_div = document.createElement("div");
    $('#preloadpacman').append(preShadow_child4_div);
    var preShadow_child5_div = document.createElement("div");
    $('#preloadpacman').append(preShadow_child5_div);
}
HUTAFG.playAfg = HuntSdk.playHutAd;
HUTAFG.playRewardedAfg = HuntSdk.playHutRewardedAd;
HUTAFG.showInterstitial = HuntSdk.showInterstitial;
HUTAFG.showReward = HuntSdk.showReward;
HUTAFG.setLoadGameComplete = HuntSdk.setLoadGameComplete;
HuntSdk.init();
_add_GdJs(function() {
    if (window["AD_CONIFG"].rewardType == "googleNewAfg" || window["AD_CONIFG"].interType == "googleNewAfg") {
        window.adsbygoogle = window.adsbygoogle || [];
        window.adBreak = window.adConfig = function(o) {
            adsbygoogle.push(o);
        }
        ;
        window.adConfig({
            preloadAdBreaks: 'on',
            sound: 'off',
        });
        if (!is_afc_loading_page) {
            $("#preShadow").show();
            HuntSdk.gotoStart();
            HuntSdk.showGame();
        }
    }
    if (is_afc_loading_page) {
        HuntSdk.showHutSplash();
    } else {
        $("#preShadow").show();
        HuntSdk.gotoStart();
        HuntSdk.showGame();
    }
    HuntSdk.updateInterval = setInterval(HuntSdk.onUpdateAds.bind(this), 1000);
});
function showMsgBox(msg, duration) {
    if (!this.msgPrompt) {
        this.msgPrompt = document.createElement('div');
        this.msgPrompt.style.cssText = "font-family:siyuan;max-width:80%;min-width:320px;padding:10px 10px 10px 10px;min-height:40px;color: rgb(255, 255, 255);line-height: 20px;text-align:center;border-radius: 4px;position: fixed;top: 40%;left: 50%;transform: translate(-50%, -50%);z-index: 999999;background: rgba(0, 0, 0,.7);font-size: 16px;";
        document.body.appendChild(this.msgPrompt)
    }
    this.msgPrompt.innerHTML = msg;
    duration = isNaN(duration) ? 2000 : duration;
    this.msgPrompt.style.display = "inline";
    this.msgPrompt.style.opacity = '1';
    setTimeout(function() {
        var d = 0.5;
        this.msgPrompt.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
        this.msgPrompt.style.opacity = '0';
        this.msgPrompt.style.display = "none"
    }
        .bind(this), duration)
}

